package cn.cocho.android.mc.log;

import java.lang.Thread.UncaughtExceptionHandler;

/**
 * RunTime异常的代理类
 * 
 * @author HAIKANG SONG
 * @date 2013-4-17 下午3:05:12
 */
public class RunTimeExceptionHandler implements UncaughtExceptionHandler {

	/**
	 * 初始化异常代理类
	 * 
	 * @author HAIKANG SONG
	 * @time 2013-4-23下午4:29:39
	 */
	public void init() {
		Thread.setDefaultUncaughtExceptionHandler(this);// 将ExceptionHandler设置为程序的默认处理器
	}

	/**
	 * 出现异常时触发
	 * 
	 * @author HAIKANG SONG
	 * @time 2013-4-23下午4:29:39
	 */
	@Override
	public void uncaughtException(final Thread t, final Throwable e) {
		LoggerUtils.error(RunTimeExceptionHandler.class.getName(), "异步线程出错：Thread[id=" + t.getId() + ": name=" + t.getName() + "]", e);
	}

}
